<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>在线生成调试</title>
</head>
<script type="text/javascript" src="/webjars/jquery/1.11.3/jquery.js"></script>
<script type="text/javascript" src="/webjars/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/webjars/github-com-sentsin-layer/3.0.3/src/layer.js"></script>
<link rel="stylesheet" type="text/css" href="/webjars/bootstrap/3.3.7/css/bootstrap.css">
<body style="background-color: #f5f5f5;">
<#include "hearder.ftl"/>
<div>
    <form role="form" id="varForm">
        <div class="form-group-in" style="padding-left: 50px;padding-right: 50px;padding-bottom: 10px;">
            <table style="width: 100%;">
                <tbody id="varBody">
                <tr class="varTr">
                    <td style="width: 10%;"><label for="varTypeLabel" style="font-size: 16px;"><label style="color: red">*</label>生成变量：</label></td>
                    <td style="width: 5%;"><label for="varTypeLabel" style="font-size: 16px;"><label style="color: red">*</label>类型：</label></td>
                    <td style="width: 8%;">
                        <select id="varType" required class="form-control"
                                placeholder="变量类型">
                            <option>String</option>
                            <option selected>Short</option>
                            <option>Long</option>
                            <option>Boolean</option>
                        </select>
                    </td>

                    <td style="width: 1%"></td>
                    <td style="width: 7%;"><label for="varNameLabel" style="font-size: 16px;"><label style="color: red;">*</label>变量名：</label>
                    </td>
                    <td style="width: 13%;">
                        <input type="text" id="varName" onchange="changeVarName(this)" required class="form-control"
                               placeholder="字母、数字、下划线组成"></td>
                    </td>
                    <td style="width: 1%"></td>

                    <td style="width: 7%;"><label for="modelIdLabel" style="font-size: 16px;"><label style="color: red;">*</label>模型ID：</label>
                    </td>
                    <td style="width: 8%;">
                        <input type="number" id="varModelId" required class="form-control"
                               placeholder="模型ID"></td>
                    </td>

                    <td style="width: 1%"></td>

                    <td style="width: 8%;"><label for="varFieldLabel" style="font-size: 16px;"><label style="color: red;">*</label>模型字段：</label>
                    </td>
                    <td style="width: 11%;">
                        <input type="text" id="varField" required class="form-control"
                               placeholder="模型字段"></td>
                    </td>

                    <td style="width: 1%"></td>
                    <td style="width: 19%;">
                        <button style="width: 50%" type="button" value="添加模型变量" onclick="addModelVar()">添加模型变量</button>
                        <button style="width: 23%" type="button" value="添加" onclick="addVar()">添加</button>
                        <button style="width: 23%" type="button" value="删除" onclick="delVar()">删除</button>
                    </td>
                </tr>
                </tbody>
            </table>
            <br>
            <button onclick="varSubmit()" type="button" style="width: 200px;" class="btn btn-var center-block"
                    aria-hidden="true">生成变量
            </button>
        </div>
    </form>
    <form role="form" id="ifForm">
        <div class="form-group-in" style="padding-left: 50px;padding-right: 50px;padding-bottom: 10px;">
            <table style="width: 100%;">
                <tbody id="tb">
                <tr>
                    <td style="width: 10%;"><label for="modelIdInputLabel" style="font-size: 16px;" onclick="changeAreaIsRed()"><label style="color: red">*</label>变量定义：</label></td>
                    <td colspan="6" style="width: 90%;"><textarea readonly ondblclick="changeAreaIsRed()" type="text" id="variableInput" required class="form-control"
                                                      placeholder="默认按填写变量生成，双击编辑框可编辑  自定义变量&#13;&#10;&#13;&#10;自定义时  参照示例中的变量定义" cols="100" rows="7"></textarea>
                    </td>
                    <#--<td style="width: 10%"></td>
                    <td><label for="codeNameInputLabel" style="font-size: 16px;"><label style="color: red">*</label>字段别名(多个用英文逗号,分隔)：</label></td>
                    <td style="width: 35%;"><input type="text" id="codeNameInput" required class="form-control"
                                                   placeholder="应用模型字段别名（必填）"></td>-->
                </tr>
                <tr class="tr20" style="height: 20px;"></tr>
                <tr class="tr">
                    <td style="width: 10%;"><label for="compRuleInputLabel" style="font-size: 16px;"><label style="color: red">*</label>判断条件：</label></td>
                    <td style="width: 35%;">
                        <input type="text" id="ifInput" required class="form-control"
                               placeholder="判断条件,参照示例中的 计算，判断规则"></td>
                        </td>

                    <td style="width: 2%"></td>
                    <td style="width: 13%;"><label for="compCoefInputLabel" style="font-size: 16px;"><label style="color: red;">*</label>满足条件结果：</label>
                    </td>
                    <td style="width: 29%;">
                        <input type="text" id="resultInput" required class="form-control"
                               placeholder="满足条件结果，若为字符串需带英文双引号"></td>
                    <td style="width: 1%"></td>
                    <td style="width:10%;text-align: center;">
                        <button style="width: 45%" type="button" value="添加" onclick="add()">添加</button>
                        <button style="width: 45%" type="button" value="删除" onclick="del()">删除</button>
                    </td>
                </tr>
                <tr><td>
                </tbody>
            </table>
            <table style="width: 100%">
                <tr><td style="width: 10%">
                <label style="font-size: 16px;" class="form-inline">默认返回结果:</label>
                    </td><td style="width: 35%">
                <input type="text" id="defaultInput" class="form-control" placeholder="默认返回结果(非必填)！若为字符串需带英文双引号">
                </label>
                </td><td style="width: 20%"></td><td style="width: 15%"></td><td style="width: 20%"></td>
                </tr>
            </table>
            <br>
            <button onclick="generateSubmit()" type="button" style="width: 200px;" class="btn btn-code center-block"
                    aria-hidden="true">生成表达式
            </button>
            <label for="name" style="font-size: 21px">可填入MachineLink的表达式</label>
            <button type="button" class="copyButton" onclick="copyML()" value="复制">复制</button>
            <button type="button" class="copySaveButton" onclick="copyAndSaveML()" value="复制并保存">复制并保存记录</button>
            <textarea style="display: none;" id="historyId" class="form-control"  rows="1"></textarea><#--style="display: none"-->
            <textarea id="inputMLArea" class="form-control" rows="15"></textarea>
        </div>

    </form>
    <form role="form">
        <div class="form-group" style="padding-left: 50px;padding-right: 50px;padding-bottom: 10px;padding-top: 20px;">
            <label for="name" style="font-size: 21px">表达式在线调试运行</label>

            <div>
                <label class="form-inline">
                    <label style="color: red;">*参数:</label><label id="mlParamsName"></label>
                    <label style="display: none" id="mlParamsValue"></label>
                    <input type="text" id="argsInput" class="form-control"
                           placeholder="多个用英文逗号分隔">
                </label>
            </div>

            <textarea id="inputRunArea" class="form-control" rows="15"></textarea>
        </div>

<button onclick="doSubmit()" type="button" style="width: 200px" class="btn btn-run center-block"
        aria-hidden="true">运行
</button>

<br>

<div style="padding-left: 50px;padding-right: 50px;padding-bottom: 10px;">
    <div class="panel panel-info">
        <div class="panel-heading">
            <h3 class="panel-title">运行信息</h3>
        </div>
        <div class="panel-body" id="complieInfoDiv">
        </div>
    </div>
</div>

<div style="padding-left: 50px;padding-right: 50px;padding-bottom: 10px;margin-bottom: 50px;">
    <div class="panel panel-primary">
        <div class="panel-heading">
            <h3 class="panel-title">运行结果</h3>
        </div>
        <div class="panel-body" id="resultDiv" style="color: green;">

        </div>
    </div>
</div>
</form>
</div>
</body>
<script>

    function changeAreaIsRed(){
        var variableInput = document.getElementById("variableInput");
        var flag=variableInput.readOnly;
        if(flag){
            variableInput.readOnly=false;
        }else {
            variableInput.readOnly=true;
        }
    }

    var index = 1;
    function add(){
        //获取新节点的索引
        index = index + 1;
        //创建一个新的节点
        var trNode = document.createElement("tr");
        trNode.innerHTML = "<tr id=\"tr\" style='margin-top: 5px;'>\n" +
            "                    <td style=\"width: 10%;\"><label for=\"compRuleInputLabel\" style=\"font-size: 16px;\"><label style=\"color: red\">*</label>判断条件：</label></td>\n" +
            "                    <td style=\"width: 35%;\">\n" +
            "                        <input type=\"text\" id=\"ifInput"+index+"\" name=\"ifInput"+index+"\" required class=\"form-control\"\n" +
            "                               placeholder=\"判断条件,参照示例中的 计算，判断规则\"></td>\n" +
            "                        </td>\n" +
            "\n" +
            "                    <td style=\"width: 2%\"></td>\n" +
            "                    <td style=\"width: 13%;\"><label for=\"compCoefInputLabel\" style=\"font-size: 16px;\"><label style=\"color: red;\">*</label>满足条件结果：</label>\n" +
            "                    </td>\n" +
            "                    <td style=\"width: 30%;\">\n" +
            "                        <input type=\"text\" id=\"resultInput"+index+"\" name=\"resultInput"+index+"\" required class=\"form-control\"\n" +
            "                               placeholder=\"满足条件结果，若为字符串需带英文双引号\"></td>\n" +
            "                </tr>";
        //trNode.innerHTML = "<tr id='tr' align='center'><td align='center'id='td'>"+index+"</td><td><input type='text'/></td><td><input type='text'/></td></tr>"
        var tbNode = document.getElementById("tb");
        //添加
        tbNode.appendChild(trNode);
    }
    function del(){
        if(index == 1){
            alert("不能再删除了呀。。。");
        }else{
            var tbNode = document.getElementById("tb");
            var delNode = tb.lastChild;
            tbNode.removeChild(delNode);
            index = index - 1;
        }
    }


    var indexVar = 1;
    function addModelVar(){
        //获取新节点的索引
        indexVar = indexVar + 1;
        //创建一个新的节点
        var trNode = document.createElement("tr");
        trNode.innerHTML = "<tr class=\"trs\">\n" +
            "                    <td style=\"width: 10%;\"></td>\n" +
            "                    <td style=\"width: 5%;\"><label for=\"varTypeLabel\" style=\"font-size: 16px;\"><label style=\"color: red\">*</label>类型：</label></td>\n" +
            "                    <td style=\"width: 8%;\">\n" +
            "                        <select id=\"varType"+indexVar+"\" required class=\"form-control\"\n" +
            "                                placeholder=\"变量类型\">\n" +
            "                            <option>String</option>\n" +
            "                            <option selected>Short</option>\n" +
            "                            <option>Long</option>\n" +
            "                            <option>Boolean</option>\n" +
            "                        </select>\n" +
            "                    </td>\n" +
            "\n" +
            "                    <td style=\"width: 1%\"></td>\n" +
            "                    <td style=\"width: 7%;\"><label for=\"varNameLabel\" style=\"font-size: 16px;\"><label style=\"color: red;\">*</label>变量名：</label>\n" +
            "                    </td>\n" +
            "                    <td style=\"width: 13%;\">\n" +
            "                        <input type=\"text\" id=\"varName"+indexVar+"\" onchange=\"changeVarName(this)\" required class=\"form-control\"\n" +
            "                               placeholder=\"字母、数字、下划线组成\"></td>\n" +
            "                    </td>\n" +
            "                    <td style=\"width: 1%\"></td>\n" +
            "\n" +
            "                    <td style=\"width: 7%;\"><label for=\"modelIdLabel\" style=\"font-size: 16px;\"><label style=\"color: red;\">*</label>模型ID：</label>\n" +
            "                    </td>\n" +
            "                    <td style=\"width: 8%;\">\n" +
            "                        <input type=\"number\" id=\"varModelId"+indexVar+"\" required class=\"form-control\"\n" +
            "                               placeholder=\"模型ID\"></td>\n" +
            "                    </td>\n" +
            "\n" +
            "                    <td style=\"width: 1%\"></td>\n" +
            "\n" +
            "                    <td style=\"width: 8%;\"><label for=\"varFieldLabel\" style=\"font-size: 16px;\"><label style=\"color: red;\">*</label>模型字段：</label>\n" +
            "                    </td>\n" +
            "                    <td style=\"width: 11%;\">\n" +
            "                        <input type=\"text\" id=\"varField"+indexVar+"\" required class=\"form-control\"\n" +
            "                               placeholder=\"模型字段\"></td>\n" +
            "                    </td>\n" +
            "                </tr>";
        //trNode.innerHTML = "<tr id='tr' align='center'><td align='center'id='td'>"+index+"</td><td><input type='text'/></td><td><input type='text'/></td></tr>"
        var tbNode = document.getElementById("varBody");
        //添加
        tbNode.appendChild(trNode);
    }

    function addVar(){
        //获取新节点的索引
        indexVar = indexVar + 1;
        //创建一个新的节点
        var trNode = document.createElement("tr");
        trNode.innerHTML = "<tr class=\"trs\">\n" +
        "                    <td style=\"width: 10%;\"></td>\n" +
        "                    <td style=\"width: 5%;\"><label for=\"compRuleInputLabel\" style=\"font-size: 16px;\"><label style=\"color: red\">*</label>类型：</label></td>\n" +
        "                    <td style=\"width: 8%;\">\n" +
        "                        <select id=\"varType"+indexVar+"\" onchange=\"changeType(this)\" required class=\"form-control\"\n" +
        "                                placeholder=\"变量类型\">\n" +
        "                            <option>String</option>\n" +
        "                            <option selected>Short</option>\n" +
        "                            <option>Long</option>\n" +
        "                            <option>Boolean</option>\n" +
        "                        </select>\n" +
        "                    </td>\n" +
        "\n" +
        "                    <td style=\"width: 1%\"></td>\n" +
        "                    <td style=\"width: 7%;\"><label for=\"varNameLabel\" style=\"font-size: 16px;\"><label style=\"color: red;\">*</label>变量名：</label>\n" +
        "                    </td>\n" +
        "                    <td style=\"width: 12%;\">\n" +
        "                        <input type=\"text\" id=\"varName"+indexVar+"\" onchange=\"changeVarName(this)\" required class=\"form-control\"\n" +
        "                               placeholder=\"字母、数字、下划线组成\"></td>\n" +
        "                    </td>\n" +
        "\n" +
        "                    <td style=\"width: 1%\"></td>\n" +
        "                    <td style=\"width: 6%;\"><label for=\"varValueLabel\" style=\"font-size: 16px;\"><label style=\"color: red;\">*</label>变量值：</label>\n" +
        "                    </td>\n" +
        "                    <td style=\"width: 23%;\" colspan=\"6\">\n" +
        "                        <input type=\"number\" id=\"varValue"+indexVar+"\" onchange=\"changeVarValue(this)\" required class=\"form-control\"\n" +
        "                               placeholder=\"变量值,默认short类型，只能输入数字\"></td>\n" +
        "                </tr>";
        var tbNode = document.getElementById("varBody");
        //添加
        tbNode.appendChild(trNode);
    }

    function delVar(){
        if(indexVar == 1){
            alert("不能再删除了呀。。。");
        }else{
            var tbNode = document.getElementById("varBody");
            var delNode = varBody.lastChild;
            tbNode.removeChild(delNode);
            indexVar = indexVar - 1;
        }
    }

    /*复制Ml代码*/
    function copyML(){
        var oInput = document.getElementById("inputMLArea");  //input 的ID
        oInput.select(); //选择对象
        document.execCommand("Copy"); //执行浏览器复制命令
        layer.msg("复制成功！");
    }

    /*复制并保存记录*/
    function copyAndSaveML(){
        var url = "/api/saveCode";
        var oInput = document.getElementById("inputMLArea");  //input 的ID
        oInput.select(); //选择对象
        var historyId = document.getElementById("historyId").value;
        console.log(historyId)
        document.execCommand("Copy"); //执行浏览器复制命令
        layer.msg("复制成功！");
        var data = {
            "historyId": historyId,
        };
        $.post(url, data, function (result) {
            //layer.msg(result.message);
        });

    }

    function isNull(val) {
        if (val == null || val == undefined || val == "") {
            return true;
        }
        return false
    }
    /**
     * 校验只要是数字（包含正负整数，0以及正负浮点数）就返回true
     **/

    function isNumber(val) {

        var regPos = /^\d+(\.\d+)?$/; //非负浮点数
        //var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
        if (isNull(val)) {
            return false;
        }
        if (!regPos.test(val)) {
            return false;
        }
        return true;
    }

    /**
     * Map转json
     * @param m
     * @returns String
     */
    function MapTOJson(m) {
        var str = '{';
        var i = 1;
        m.forEach(function (item, key, mapObj) {
            if(mapObj.size == i){
                str += '"'+ key+'":"'+ item + '"';
            }else{
                str += '"'+ key+'":"'+ item + '",';
            }
            i++;
        });
        str +='}';
//    console.log(str);
        return str;
    }

    function varSubmit() {
        var fromData = getVarValuesMap("varForm");
        if(isNull(fromData)){
            layer.msg("需填写生成变量参数！");
            return;
        }
        var inputText = varDefStr(fromData)
        if(isNull(inputText)){
            layer.msg("变量名不可重复！");
            return;
        }
        $("#variableInput").html(inputText);
        layer.msg("生成变量成功！");
        console.log(fromData);
    }

    function varDefStr(fromData) {
        var str = "";
        var map = new Map();
        var isAllmap = new Map();
        for (var i = 0; i < fromData.length; i++) {
            map = fromData[i];
            if(map.size == 4){
                var arr4=new Array(4);
                for (var [key, value] of map) {
                    if(key.indexOf("varType")!= -1){
                        if (value == 'Short'){
                            arr4[3] = ".shortValue();\n";
                        }else if(value == 'Long'){
                            arr4[3] = ".longValue();\n";
                        }else{
                            arr4[3] = ";\n";
                        }
                    }
                    if(key.indexOf("varName")!= -1){
                        arr4[0] = "def "+value +" = ";
                        var field=isAllmap.get(value);
                        if(field!=undefined&&field!=null&&field!=""){
                            return null;
                        }
                        isAllmap.set(value,value);
                    }
                    if(key.indexOf("varModelId")!= -1){
                        arr4[1] = "N_"+value+"_1";
                    }
                    if(key.indexOf("varField")!= -1){
                        arr4[2] = "."+value;
                    }
                }
                str += arr4.join('');
                continue;

            }else if(map.size == 3){
                var arr3=new Array(3);
                var flag = false;
                for (var [key, value] of map) {
                    if(key.indexOf("varType")!= -1){
                        arr3[2] = ";\n";
                        if (value == 'String'){
                            flag = true;
                        }
                    }
                    if(key.indexOf("varName")!= -1){
                        arr3[0] = "def "+value +" = ";
                        var field = isAllmap.get(value);
                        if(field!=undefined&&field!=null&&field!=""){
                            return null;
                        }
                        isAllmap.set(value,value);
                    }
                    if(key.indexOf("varValue")!= -1){
                        arr3[1] = flag?'"'+value+'"':value;
                    }
                }
                str += arr3.join('');
                continue;
            }
            layer.msg("生成参数变量获取失败！");
            continue;
        }

        return str;
    }

    function changeType(inType) {
        var id = "varType";
        var type= inType.attributes.id.nodeValue;
        var value = inType.value;
        var idStr = type.substring(id.length,type.length);
        var valStr = "varValue" + idStr;
        var doc=document.getElementById(valStr);
        if(value == 'Short'||value == 'Long'){
            doc.placeholder = "只能输入数字！";
            doc.type = "number";
        }else if(value == 'Boolean'){
            doc.type = "text";
            doc.placeholder = "只能输入true/false！"
        }
        else {
            doc.type = "text";
            doc.placeholder = "输入变量值！";
        }
    }

    function changeVarValue(varValue){
        var id = "varValue";
        var type= varValue.attributes.id.nodeValue;
        var value = varValue.value;
        var idStr = type.substring(id.length,type.length);
        var valStr = "varType" + idStr;
        var doc=document.getElementById(valStr);
        if(doc.value == 'Boolean'){
            if(value != true&&value != false){
                layer.msg("Boolean类型变量只能输入true/false");
            }
        }
    }

    function changeVarName(varName) {
        var nameValue = varName.value;
        var patrn=/^(\w){1,20}$/;
        if(!patrn.test(nameValue)){
            layer.msg("变量名只能输入1-20个字母、数字、下划线！");
        }
    }

    function getVarValuesMap(formId) {
        var form = document.getElementById(formId);
        var arrayData = new Array();
        var map = new Map();
        var selectNum = 0;
        for (let i = 0; i < form.length ; i++) {
            if(form[i].localName == 'select'){
                selectNum ++;
                if(selectNum>1){
                    arrayData.push(map);
                    map = new Map();
                    map.set(form[i].attributes.id.nodeValue,form[i].value);
                }else{
                    map.set(form[i].attributes.id.nodeValue,form[i].value);
                }
            }
            if(form[i].localName == 'input') {
                if(isNull(form[i].value)){
                    return null;
                }
                map.set(form[i].attributes.id.value, form[i].value);
            }
            if(i==form.length-1){
                arrayData.push(map);
            }

        }
        return arrayData;
    }

    function generateSubmit() {
        var url = "/api/generateCode";
        var variableInput = $("#variableInput").val()
        var ifInput = $("#ifInput").val();
        var resultInput = $("#resultInput").val();

        // if (!isNumber(modelIdInput)) {
        //     layer.msg("模型ID必填,且为必须为数字！");
        //     return;
        // }

        if(isNull(variableInput)){
            layer.msg("需填写变量！");
            return;
        }

        var fromData = getInputValuesMap(variableInput,"ifForm");


        var data = {
            "data": map2JsonString(fromData),
        };
        $.post(url, data, function (result) {
            layer.msg(result.message);
            //设置代码信息
            $("#inputMLArea").val(result.data.MLCodeText);
            $("#inputRunArea").val(result.data.RUNCodeText);
            //var mlParamsNameLabel = document.getElementById('mlParamsName'); // 查找一个id为label的节点
            $("#mlParamsName").html(result.data.MLCodeParamName);
            //var mlParamsValueLabel = document.getElementById('mlParamsValue');
            $("#mlParamsValue").html(result.data.MLCodeParam);
            $("#historyId").html(result.data.historyId);
        });
    }

    //获取指定form中的所有的<input>对象以及值
    function getInputValuesMap(variableInput,formId) {
        var result = new Map();
        result.set("variableInput",variableInput);
        var form = document.getElementById(formId);
        var tagElements = form.getElementsByTagName('input');
        var arrayData = new Array();
        var defaultData = "";
        var map = new Map();
        for (var j = 0; j < tagElements.length; j++){
            if(j==tagElements.length-1){
                defaultData = tagElements[j].value;
                break;
            }
            if(j%2==0){
                map = new Map();
            }
            var nodeValue=tagElements[j].value;
            if(isNull(nodeValue)){
                layer.msg("需填写 判断条件/条件结果！");
                return ;
            }
            map.set(tagElements[j].attributes.getNamedItem("id").nodeValue,tagElements[j].value);
            if(j%2!=0) {
                arrayData.push(map2JsonString(map));
            }
        }
        result.set("ifData",arrayData);
        result.set("defaultData",defaultData);
        return result;
    }

    function map2JsonString(fromData) {
        var obj= Object.create(null);
        for (var[k,v] of fromData) {
            obj[k] = v;
        }
        return JSON.stringify(obj);
    }

    function getValues(inputName) {
        var values = [];
        $('input[name=' + inputName + ']').each(function(i, v) {
            values.push(v.value);
        })
        console.log(values);
        return values.join(',');
    }


    function doSubmit() {
        var url = "/run/compile";
        var executeArgs = $("#argsInput").val().trim();
        var mlParamsName = document.getElementById('mlParamsName').innerText;
        var mlParamsValue = document.getElementById('mlParamsValue').innerText;
        if (!isNull(mlParamsName)&&isNull(executeArgs)) {
            layer.msg("字段参数值必填！");
            return;
        }
        var runArea = $("#inputRunArea").val();
        if (isNull(runArea)) {
            layer.msg("需填入可执行代码！");
            return;
        }

        var data = {
            "code": $("#inputRunArea").val(),
            "method": "execute",
            "paramsName": mlParamsName,
            "paramsValue": mlParamsValue,
            "params": executeArgs
        };
        $.post(url, data, function (result) {
            layer.msg(result.message);
            //设置执行信息
            $("#complieInfoDiv").html("运行耗时(毫秒)：" + result.executeDurationTime + "ms<br>编译状态：" + result.message);
            //设置执行结果
            $("#resultDiv").html(result.executeResult);
        });
    }

    function timeLimitClick() {
        if ($("#timeLimitCheckBox").prop("checked")) {
            $("#timeLimitInput").show();
        } else {
            $("#timeLimitInput").hide();
        }
    }

    function argsCheckBoxClick() {
        if ($("#argsCheckBox").prop("checked")) {
            $("#argsInput").show();
        } else {
            $("#argsInput").hide();
        }
    }
</script>
<style>

    .btn-var {
        color: #fff;
        background-color: mediumvioletred;
        border-color: mediumvioletred;
    }
    .btn-code {
        color: #fff;
        background-color: deepskyblue;
        border-color: deepskyblue;
    }

    .btn-run {
        color: #fff;
        background-color: #008e00;
        border-color: #008e00;
    }

    .panel-primary .panel-heading {
        color: #fff;
        background-color: #32a0dc;
        border-color: #32a0dc;
    }
    .panel-body{
        font-size: 16px;
    }
    label {
        margin-bottom: 0px;
    }

    .tr20{
        height: 20px;
    }
    .form-control {
        margin: 3px;
    }


    .copyButton {
        padding: 0.1em 1em;
        text-align: center;
        text-decoration: none;
        color: #2194E0;
        font-size: 18px;
        display: inline-block;
        position: relative;
        overflow: hidden;
        border: none;
        background-color: #f5f5f5;
    }

    .copySaveButton {
        padding: 0.1em 1em;
        text-align: center;
        text-decoration: none;
        color: #2194E0;
        font-size: 18px;
        display: inline-block;
        position: relative;
        overflow: hidden;
        border: none;
        background-color: #f5f5f5;
    }

</style>
</html>